package ngat.oss;

import java.io.*;
import java.util.*;

import ngat.phase2.*;

public class ScheduleItemComparator implements Serializable, Comparator {
    
    public int compare (Object o1, Object o2) {
	
	if (! (o1 instanceof ScheduleDescriptor) ||
	    ! (o2 instanceof ScheduleDescriptor))
	    throw new ClassCastException("Compare:: Not both ScheduleDescriptors: ("+
					 (o1 == null ? "NULL": o1.getClass().getName())+","+
					 (o2 == null ? "NULL": o2.getClass().getName())+")");
	
	ScheduleDescriptor s1 = (ScheduleDescriptor)o1;
	ScheduleDescriptor s2 = (ScheduleDescriptor)o2;
	
	if (s1.getScore() < s2.getScore())
	    return -1;
	else if
	    (s1.getScore() > s2.getScore())
	    return 1;
	return 0;
	
    }
    
}
